home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / ici / ici.cpi / func.h < prev    next >
C/C++ Source or Header  |  1994-10-27  |  1KB  |  55 lines

  1. #ifndef    ICI_FUNC_H
  2. #define    ICI_FUNC_H
  3.  
  4. #ifndef    ICI_OBJECT_H
  5. #include "object.h"
  6. #endif
  7.  
  8. struct func
  9. {
  10.     object_t    o_head;
  11.     array_t    *f_code;    /* The code of this function, atom. */
  12.     array_t    *f_args;    /* Array of argument names. */
  13.     struct_t    *f_autos;    /* Prototype struct of autos (incl. args). */
  14.     string_t    *f_name;    /* Some name for the function (diagnostics). */
  15. };
  16.  
  17. struct cfunc
  18. {
  19.     object_t    o_head;
  20.     char    *cf_name;
  21.     int        (*cf_cfunc)();
  22.     int        (*cf_arg1)();
  23.     char    *cf_arg2;
  24. };
  25. #define    cfuncof(o)    ((cfunc_t *)(o))
  26. #define    funcof(o)    ((func_t *)(o))
  27. #define    isfunc(o)    ((o)->o_type == &func_type)
  28.  
  29. #define    O_CFUNC        0x10
  30. #define    CF_OBJ        {0, O_ATOM|O_CFUNC, 1, 0, &func_type}
  31.  
  32. /*
  33.  * The n'th argument (first is 0) during execution of a function's C code.
  34.  */
  35. #define    ARG(n)        (o_top[-2 - n])
  36.  
  37. /*
  38.  * Count of actual arguments to this C function.
  39.  */
  40. #define    NARGS()        (opof(x_top[-1])->op_code)
  41.  
  42. /*
  43.  * A pointer to the first arg to this C function, decrement for next
  44.  * and subsequent.
  45.  */
  46. #define    ARGS()        (&o_top[-2])
  47.  
  48. /*
  49.  * Return the cf_arg1 and cf_arg2 fields of the current C function.
  50.  * The first is a function pointer, the second a char *.
  51.  */
  52. #define    CF_ARG1()    (cfuncof(o_top[-1])->cf_arg1)
  53. #define    CF_ARG2()    (cfuncof(o_top[-1])->cf_arg2)
  54. #endif
  55.